<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet 
	version="1.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	xmlns:msxml="urn:schemas-microsoft-com:xslt"
	xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:CommerceLibrary="urn:CommerceLibrary" xmlns:pm.library="urn:pm.library" 
	exclude-result-prefixes="msxml pm.library umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets CommerceLibrary pm.library ">


<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:param name="currentPage"/>

<xsl:template match="/">

    <xsl:variable name="messageId" select="concat('0', umbraco.library:RequestQueryString('id'))" />
    <xsl:variable name="result" select="pm.library:GetPrivateMessage($messageId)" />
    <xsl:choose>
      <xsl:when test="string-length($result/error) = 0">
          <xsl:for-each select="$result//privatemessage">
		<h3><xsl:value-of select="message/subject" /></h3>
		<p><xsl:value-of select="umbraco.library:ReplaceLineBreaks(message/body)" disable-output-escaping="yes" /></p>
		<p>Sent by <strong><xsl:value-of select="umbraco.library:GetMemberName(message/memberid)" /></strong> on
		<strong><xsl:value-of select="umbraco.library:FormatDateTime(message/createdate, 'dd MMMM, yyyy')" /></strong></p>
         		<p>
			[ <a href="/private/pm{Exslt.ExsltStrings:lowercase(recipient/folder)}.aspx">CANCEL</a> ] 
			[ <a href="/private/pm{Exslt.ExsltStrings:lowercase(recipient/folder)}.aspx?delete={message/messageid}" onclick="return confirm('Are you sure you want to delete this message?');">DELETE</a> ]
			<xsl:if test="message/memberid != recipient/memberid">
				[ <a href="/private/pmcompose.aspx?id={$messageId}">REPLY</a> ] 
			</xsl:if>
		</p> 
	</xsl:for-each>	
	<xsl:variable name="tmp" select="pm.library:UpdatePrivateMessageStatus($messageId, 'Read')" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$result/error" />
      </xsl:otherwise>
    </xsl:choose>

</xsl:template>

</xsl:stylesheet>